//玩家拥有的道具

import { MapWrap } from "../../../Core/FrameEx/ES5Ex";
import { GLocal } from "../../../Core/Manager/DataPool";
import RJXItem from "../RunTime/RunRaw/RJXItem";
const { ccclass } = cc._decorator;
@ccclass
export default class LOwnItems extends GLocal {
    public $localKey = "LOwnProps";
    private $isFrist = true;
    private $ownItems = {}


    public onInit() {
        this.load();
        this.set();
    }


    public set isFrist(v: boolean) {
        this.$isFrist = v;
        this.set()
    }

    public get isFrist() {
        return this.$isFrist;
    }

    public getAllItems() {
        return this.$ownItems;
    }

    public save(mapData: MapWrap<string, RJXItem[]>) {
        this.$ownItems = {}
        mapData.forEach((value: RJXItem[], key: string) => {
            if (value.length) {
                let items = [];
                value.forEach(item => {
                    items.push([item.id, item.type, item.num])
                })
                this.$ownItems[key] = items;
            }
        });
        this.set();
    }
}